package com.paiai.lslease.base;

public class AppResult implements java.io.Serializable{
	
	private static final long serialVersionUID = 705456210025309159L;
	
	public static final int SUCCESS = 1;
	
	public static final int FAIL = 0;
	
	public static final String FORMATTER = "yyyy年MM月dd日 HH:mm";
	
	private int status;
	private String msg;
	private Object data;

	
	public AppResult(){
	}
	
	public AppResult(int status, String msg) {
		this.status = status;
		this.msg = msg;
	}
	
	public AppResult(int status, String msg, Object data) {
		this.status = status;
		this.msg = msg;
		this.data = data;
	}

	
	public static AppResult newFailResult(String error){
		return new AppResult(FAIL,error,null);
	}
	
	public static AppResult newFailResult(String error,Object data){
		return new AppResult(FAIL,error,data);
	}
    
    public static AppResult newSusscessResult(Object data){
    	return newSusscessResult("操作成功",data);
	}
	
    public static AppResult newSusscessResult(String mess,Object data){
    	return new AppResult(SUCCESS,mess,data);
	}
    

	/**
     * 是否成功
     */
    public boolean equalSuccess(){
    	return this.getStatus() == SUCCESS;
    }
 

    @Override
	public String toString() {
		return "AppResult [status=" + status + ", msg=" + msg + ", data="
				+ data + "]";
	}

	public int getStatus() {
		return status;
	}

	public AppResult setStatus(int status) {
		this.status = status;
		return this;
	}

	public String getMsg() {
		return msg;
	}

	public AppResult setMsg(String msg) {
		this.msg = msg;
		return this;
	}

	public Object getData() {
		return data;
	}

	public AppResult setData(Object data) {
		this.data = data;
		return this;
	}
	
	
}
